import { createElement, LinkHTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { commentAuthorDefaultProps } from './defaultProps';
import type { CommentAuthorOptions } from './type';

export interface CommentAuthorProps extends CommentAuthorOptions, LinkHTMLAttributes<HTMLLinkElement> {}

const CommentAuthor: FC<CommentAuthorProps> = (props) => {
  const { className, children, forwardedRef, ...commentAuthorProps } = props;

  return createElement(
    'a',
    { ref: forwardedRef, className: classNames('author', className), ...commentAuthorProps },
    children,
  );
};

CommentAuthor.displayName = 'CommentAuthor';
CommentAuthor.defaultProps = commentAuthorDefaultProps;

export default CommentAuthor;
